package com.flycun;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication
@EnableEurekaClient
@EnableFeignClients
@EnableCircuitBreaker
@RestController
public class OrderWebApplication {
	private static final Logger logger = LoggerFactory.getLogger(OrderWebApplication.class);
	@Autowired
	UserServiceRemote userServiceRemote;

	public static void main(String[] args) throws Exception {
		SpringApplication.run(OrderWebApplication.class, args);
	}

	@RequestMapping("/order/user/{id}")
	public Object getUser(@PathVariable("id") int id) {
		Object object = userServiceRemote.getUser(id);
		logger.info("getUserInfo:{},{}",id,object);
		return object;
	}
	
	@RequestMapping("/order/user/credit/{id}")
	public Object getCredit(@PathVariable("id") int id) {
		Object object = userServiceRemote.getCredit(id);
		logger.info("getCredit:{},{}",id,object);
		return object;
	}

}